package blogger.client.ui.utils;



import blogger.client.ui.panels.SlidePanel;

import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.ComplexPanel;


public class SlideTimer extends Timer {
	ComplexPanel panel;
	boolean forward;
	Working working;
    
    private int x = 500;

	public SlideTimer(ComplexPanel panel, Working working,
			boolean forward) {
		this.panel = panel;
		this.forward = forward;
		this.working = working;
	}

	public void run() {
		if (forward) {
			panel.getElement().getStyle().setProperty("width", "" + x + "");
			x -= 2;
			if (x <= 20) {
				cancel();
				forward = false;
				working.set(false);
				x = 20;
			}
		} else {
			panel.getElement().getStyle().setProperty("width", "" + x + "");
			x += 2;
			if (x >= 500) {
				cancel();
				forward = true;
				working.set(false);
				x = 500;
			}
		}
	}

	public boolean isForward() {
		return forward;
	}
}
